/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package EA_Model.IEC61970.Outage.impl;

import EA_Model.IEC61970.Core.impl.IdentifiedObjectImpl;

import EA_Model.IEC61970.Domain.AbsoluteDateTime;

import EA_Model.IEC61970.Outage.OutagePackage;
import EA_Model.IEC61970.Outage.SwitchState;
import EA_Model.IEC61970.Outage.SwitchingOperation;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Switching Operation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link EA_Model.IEC61970.Outage.impl.SwitchingOperationImpl#getNewState <em>New State</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Outage.impl.SwitchingOperationImpl#getOperationTime <em>Operation Time</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SwitchingOperationImpl extends IdentifiedObjectImpl implements SwitchingOperation {
	/**
	 * The default value of the '{@link #getNewState() <em>New State</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNewState()
	 * @generated
	 * @ordered
	 */
	protected static final SwitchState NEW_STATE_EDEFAULT = SwitchState.OPEN;

	/**
	 * The cached value of the '{@link #getNewState() <em>New State</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNewState()
	 * @generated
	 * @ordered
	 */
	protected SwitchState newState = NEW_STATE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getOperationTime() <em>Operation Time</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperationTime()
	 * @generated
	 * @ordered
	 */
	protected AbsoluteDateTime operationTime;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SwitchingOperationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OutagePackage.Literals.SWITCHING_OPERATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SwitchState getNewState() {
		return newState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNewState(SwitchState newNewState) {
		SwitchState oldNewState = newState;
		newState = newNewState == null ? NEW_STATE_EDEFAULT : newNewState;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OutagePackage.SWITCHING_OPERATION__NEW_STATE, oldNewState, newState));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AbsoluteDateTime getOperationTime() {
		if (operationTime != null && operationTime.eIsProxy()) {
			InternalEObject oldOperationTime = (InternalEObject)operationTime;
			operationTime = (AbsoluteDateTime)eResolveProxy(oldOperationTime);
			if (operationTime != oldOperationTime) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OutagePackage.SWITCHING_OPERATION__OPERATION_TIME, oldOperationTime, operationTime));
			}
		}
		return operationTime;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AbsoluteDateTime basicGetOperationTime() {
		return operationTime;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOperationTime(AbsoluteDateTime newOperationTime) {
		AbsoluteDateTime oldOperationTime = operationTime;
		operationTime = newOperationTime;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OutagePackage.SWITCHING_OPERATION__OPERATION_TIME, oldOperationTime, operationTime));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OutagePackage.SWITCHING_OPERATION__NEW_STATE:
				return getNewState();
			case OutagePackage.SWITCHING_OPERATION__OPERATION_TIME:
				if (resolve) return getOperationTime();
				return basicGetOperationTime();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OutagePackage.SWITCHING_OPERATION__NEW_STATE:
				setNewState((SwitchState)newValue);
				return;
			case OutagePackage.SWITCHING_OPERATION__OPERATION_TIME:
				setOperationTime((AbsoluteDateTime)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OutagePackage.SWITCHING_OPERATION__NEW_STATE:
				setNewState(NEW_STATE_EDEFAULT);
				return;
			case OutagePackage.SWITCHING_OPERATION__OPERATION_TIME:
				setOperationTime((AbsoluteDateTime)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OutagePackage.SWITCHING_OPERATION__NEW_STATE:
				return newState != NEW_STATE_EDEFAULT;
			case OutagePackage.SWITCHING_OPERATION__OPERATION_TIME:
				return operationTime != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (newState: ");
		result.append(newState);
		result.append(')');
		return result.toString();
	}

} //SwitchingOperationImpl
